﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Fize.IO
{
    public class Stream
    {
        
        /// <summary>
        /// 写入一行
        /// </summary>
        /// <param name="path">文件路径，不存在则新建</param>
        /// <param name="content">写入的单行内容</param>
        /// <param name="encoding">指定编码</param>
        public static void WriteLine(string path, string content, string encoding)
        {
            StreamWriter sw = new StreamWriter(path, true, Encoding.GetEncoding(encoding));
            sw.WriteLine(content);
            sw.Flush();
            sw.Close();
        }

        /// <summary>
        /// 以UTF-8编码写入一行
        /// </summary>
        /// <param name="path">文件路径，不存在则新建</param>
        /// <param name="content">写入的单行内容</param>
        public static void WriteLine(string path, string content)
        {
            WriteLine(path, content, "UTF-8");
        }
    }
}
